package com.whu.tcx01.road;

import org.springframework.beans.factory.annotation.Autowired;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class RoadUtil {

    public static List updateElement(List objList, Object oldObj, Object newObj){
        int position = objList.indexOf(oldObj);
        objList.remove(position);
        objList.add(position, newObj);

        return objList;
    }

    public static List<String> readFile02(String path) throws IOException {
        // 使用一个字符串集合来存储文本中的路径 ，也可用String []数组
        List<String> list = new ArrayList<>();
        FileInputStream fis = new FileInputStream(path);
        // 防止路径乱码   如果utf-8 乱码  改GBK     eclipse里创建的txt  用UTF-8，在电脑上自己创建的txt  用GBK
        InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
        BufferedReader br = new BufferedReader(isr);
        String line = "";
        RoadServiceImpl roadService = null;
        while ((line = br.readLine()) != null) {
            String[] split = line.split("\t");
            long newRoadid = Long.parseLong(split[0]);
            for(int i = 4; i < split.length; i++){

            }
        }
        br.close();
        isr.close();
        fis.close();
        return list;
    }
}
